/*
* Author: Foldcc
* Mail:   lhyuau@qq.com
* AudioManagerEditor
*/

using System.Collections.Generic;
using Framework.Audio;
using UnityEditor;
using UnityEngine;

namespace Framework.AudioEditor
{
    [CustomEditor(typeof(AudioManager))]
    public class AudioManagerEditor : UnityEditor.Editor
    {

        public override void OnInspectorGUI()
        {
            if (this.target == null)
            {
                return;
            }
            GUILayout.Space(20);
            
            this.serializedObject.Update();
            Dictionary<string, string> dictionary = AudioManager.Instance.EditorLOG();
            GUILayout.Space(10);
            GUILayout.Box(new GUIContent($"音频资源记录总数: {dictionary?.Count ?? 0}"), GUILayout.ExpandWidth(true));
            GUILayout.Space(10);
            GUILayout.Box(new GUIContent("音频文件\t是否加载\t资源引用数\n"), GUILayout.ExpandWidth(true));
            string log = "";
            if (dictionary!=null)
            {
                foreach (var dictionaryKey in dictionary.Keys)
                {
                    log += $"{dictionaryKey}{dictionary[dictionaryKey]}\n";
                }
            }
            GUILayout.Box(new GUIContent(log), GUILayout.ExpandWidth(true));
            this.serializedObject.ApplyModifiedProperties();
        }
    }
}